<%--
  Created by IntelliJ IDEA.
  User: eaglet
  Date: 2024/3/13
  Time: 10:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册页面</title>

</head>
<body>
  <div>
    <h3>欢迎注册</h3>
  </div>
  <div>
      <form action="registerServlet" method="post">
          <div>
              用户名：<input type="text" id="username" name="username">
          </div>
          <div>
              密码：<input type="password" id="userpass" name="userpass">
          </div>
          <div>
              重复密码：<input type="password" id="reuserpass" name="reuserpass">
          </div>
          <div>
              <input type="submit" onclick="return checkinput()" value="注册">
          </div>
      </form>
  </div>
  <script type="text/javascript">
      function checkinput() {
          var username = document.getElementById("username").value;
          var userpass = document.getElementById("userpass").value;
          var reuserpass = document.getElementById("reuserpass").value;

          //trim()方法是去除空格，不允许输入空格内容
          if (username.trim()== "" || username.trim() == null) {
              alert("用户名不能为空！");
              return false;
          }

          if (userpass.trim() == "" || userpass.trim() == null) {
              alert("密码不能为空！");
              return false;
          }

          if(userpass.trim()==reuserpass.trim()){
              return true;
          }else{
              alert("两次密码不一样，请重新输入");
              return false;
          }
      }
  </script>
</body>
</html>
